import request from "@/utils/axios";
/**
 * 注册
 * @returns {Promise<{token,google_secret,return_msg,return_code}>}
 */
export const reqRegister = ({ mail, code, password }) => {
  return request.post("/register", {
    mail,
    code,
    password,
  });
};

/**
 * 发送验证码
 * @returns {Promise<{return_code,return_msg}>}
 */
export const reqSendCode = (mail) => {
  return request.post("/sendCode", {
    mail,
  });
};

/**
 * 登录接口
 * @returns {Promise<{return_code,return_msg,token,mail,user_id}>}
 */
export const reqLogin = ({ mail, code, password }) => {
  return request.post("/login", {
    mail,
    code,
    password,
  });
};

/**
 * 找回密码
 * @returns {Promise<{return_code,return_msg}>}
 */
export const reqFindPassword = ({ mail, code,password }) => {
  return request.post("/forgetPassword", {
    mail,
    code,
    password,
  });
};

/**
 * 注销
 * @returns {Promise<{return_code,return_msg}>}
 */
export const reqLogout = (token) => {
  return request.post("/loginOut", {
    token,
  });
};

/**
 * 获取支付方式列表
 * @returns {Promise<{return_code,return_msg,data: Array<{id,name,channel_code,pay_type_code,pay_type_code_name,country}>}>}
 */
export const reqGetChannelList = (user_id,country) => {
  return request.post("/getChannelList", {
    user_id,
    country,
  });
};

/**
 * 充值
 * @returns {Promise<{return_code,return_msg,pay_link}>}
 */
export const reqRecharge = ({
  user_id,
  pay_type_code_id,
  payphone,
  payname,
  payemail,
  country,
  order_amount,
  currency,
  bankcode,
  desc,
}) => {
  return request.post("/createCharge", {
    user_id,
    pay_type_code_id,
    payphone,
    payname,
    payemail,
    country,
    order_amount,
    currency,
    bankcode,
    desc,
  });
};

/**
 * 首页
 * @returns {Promise<{return_code,return_msg,data:Array<{
 *   id,
 *   user_id,
 *   currency,
 *   amount,
 *   freeze_amount,
 *   risk_margin,
 *   risk_margin_set,
 *   created_at,
 *   updated_at,
 *   status,
 * }>}>}
 */
export const reqHome = (user_id) => {
  return request.post("/index", {
    user_id,
  });
};

/**
 * 首页资金变化
 * @returns {Promise<{return_code,return_msg,data: Array<{
 *   {
 *    currency,
 *    last_amount,
 *    created_at,
 * }>}>}
 */
export const reqBalanceLog = ({ user_id, currency }) => {
  return request.post("/balanceLog", {
    user_id,
    currency,
  });
};

/**
 * 账户-每日
 * @returns {Promise<{return_code,return_msg,data: Array<{
 *   {
 *    id,
 *    user_id,
 *    currency,
 *    amount,
 *    freeze_amount,
 *    risk_margin,
 *    risk_margin_set,
 *    created_at,
 *    updated_at,
 *    status,
 * }>}>}
 */
export const reqDaily = ({ user_id, currency, startdata, enddata }) => {
  return request.post("/daily", {
    user_id,
    currency,
    startdata,
    enddata,
  });
};

/**
 * 渠道代理汇总
 * @returns {Promise<{return_code,return_msg,pay_link}>}
 */
// export const reqChannelInterface = (ouser_id) => {
//   return request.post("/channelInterface", {
//     ouser_id,
//   })
// }

/**
 * 商户信息
 * @returns {Promise<{return_code,return_msg,data:Array<{id,user_id,companty_name,license_code,contacts,phone,mail,bank_name,account_name,account,currency,exchange_rate,created_at,updatedd_at}>,level:Array<{level}>}>}
 */
export const reqSelMerchant = (user_id) => {
  return request.post("/selMerchant", {
    user_id,
  });
};

/**
 * 渠道信息显示
 * @returns {Promise<{return_code,return_msg,bdata:Array<{bid,country,currency,back_name,status,costData:[]|{}>}>}
 */
export const reqChannelInfo = (user_id) => {
  return request.post("/channelInfo", {
    user_id,
  });
};

/**
 * 渠道信息申请开通
 * @returns {Promise<{return_code,return_msg}>}
 */
export const reqChannelApply = ({ user_id, cid, bid }) => {
  return request.post("/channelApply", {
    user_id,
    cid,
    bid,
  });
};

/**
 * 账户-提现-显示
 */
export const reqShowWithdrawal = (user_id) => {
  return request.post("/showWithdrawal", {
    user_id,
  });
};

/**
 *  账户-提现
 */

export const reqCreateWithdrawal = ({ user_id, code, order_amount,currency }) => {
  return request.post("/createWithdrawal", {
    user_id,
    code,
    order_amount,
    currency
  });
};

/**
 * 账户-获取代付方式列表
 */
export const reqGetWithdrawalList = (user_id) => {
  return request.post("/getWithdrawalList", {
    user_id,
  });
};

/**
 * 账户-代付
 */
export const reqCreateRepay = ({ user_id, bank_id, order_amount, acc_no }) => {
  return request.post("/createRepay", {
    user_id,
    bank_id,
    ucid: '4',
    order_amount,
    acc_no,
    code: '66669999',
    acc_name: '测试',
  });
};

/**
 * 账户-详情
 */
export const reqSelAllOrderList = ({
  user_id,
  currency,
  type,
  startdata,
  enddata,
  platform_order,
  merchant_order,
  status,
  page,
}) => {
  return request.post("/selAllOrderList", {
    user_id,
    currency,
    type,
    startdata,
    enddata,
    platform_order,
    merchant_order,
    status,
    page,
  });
};

/**
 * 账户-代付-列表显示
 */
export const reqShowRepayList = ({ user_id, page }) => {
  return request.post("/showRepayList", {
    user_id,
    page,
  });
};

/**
 * 账户-提现-列表显示
 */
export const reqShowWithdrawalList = ({ user_id, page }) => {
  return request.post("/showWithdrawalList", {
    user_id,
    page,
  });
};


/**
 * 充值-列表显示
 */
export const reqShowChargeList = ({ user_id, page }) => {
  return request.post("/showChargeList", {
    user_id,
    page,
  });
};